﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service.BusinessLayer.Entities;
using Service.DataAccess.DataAccessHelper;
using System.Data.SqlClient;
using System.Data;

namespace Service.DataAccess.DataAccessLogic
{
    public class ChiTietNhapHang_DA
    {

        public void them(ChiTietNhapHang ctnh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[5];
            par[0] = new SqlParameter("@masn", ctnh.Masn);
            par[1] = new SqlParameter("@mamh", ctnh.Mamh);
            par[2] = new SqlParameter("@mawash", ctnh.Mawash);
            par[3] = new SqlParameter("@soluongnhap", ctnh.Soluongnhap);
            par[4] = new SqlParameter("@dongianhap", ctnh.Dongianhap);
            help.InsertQuery("sp_chitietnhaphang_them", par);
        }
        public void sua(ChiTietNhapHang ctnh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[5];
            par[0] = new SqlParameter("@masn", ctnh.Masn);
            par[1] = new SqlParameter("@mamh", ctnh.Mamh);
            par[2] = new SqlParameter("@mawash", ctnh.Mawash);
            par[3] = new SqlParameter("@soluongnhap", ctnh.Soluongnhap);
            par[4] = new SqlParameter("@dongianhap", ctnh.Dongianhap);
            help.UpdateQuery("sp_chitietnhaphang_sua", par);
        }
        public void xoa(string masn,string mamh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[2];
            par[0] = new SqlParameter("@masn", masn);
            par[1] = new SqlParameter("@mamh", mamh);
            help.DeleteQuery("sp_chitietnhaphang_xoa", par);
        }
        public DataSet layds(int makh)
        {
            Helper help = new Helper();
            DataSet ds = new DataSet();
            SqlParameter par = new SqlParameter("@makh", makh);
            ds = help.SelectQuery("sp_chitietnhaphang_layds_ma",par);
            return ds;
        }
    }
}
